/**
 * 权限相关的数据
 * Created by gcc on 2017/9/29.
 */
import Vue from "vue";
import  { Tooltip } from 'view-design'
import {isEmpty} from "../../../js/commonUtils";
const tableRowStateTitle = function (self) {
  return {
    title: '订单状态',
    key: 'orderState',
    align: 'center',
    width: 140,
    render: (h, params) => {
      let state = self.orderStateDict.find(item => item.value == params.row.orderState);
      return h('div', state==null?"":state.name);
    }
  }
};

// 页码相关
let page = {
  total: 1,
  startIndex: 0,
  stepNumber: 40,
  currentPage: 1
};

// 和网络交互相关的参数
let params = {
  //搜索条件
  userName: '',
  orderStartDate: "",
  orderEndDate:"",
};

// 页面的数据源
let data = {
  orderList: []
};

let table = {
  tableMain: {
    tableRowIndex: {
      type: 'index',
      title: '#',
      key: 'index',
      fixed: 'left',
      align: 'center',
      width: 60
    },
    tableRowNumber: {
      title: '订单流水号',
      key: 'serialNumber',
      align: 'center',
      width: 240
    },
    tableRowUser: {
      title: '用户',
      key: 'userName',
      align: 'center',
      width: 150,
      render: (h, params) => {
        let username = isEmpty(params.row.userName)?"":Vue.prototype.$tiyHideUsername(params.row.userName);
        return (
          <div>
            <Tooltip content={params.row.userName} placement="top">
              <span style="padding:6px;font-size:13px" >
                {username}
              </span>
            </Tooltip>
          </div>
        );
      }
    },
    tableRowCountry: {
      title: '国家',
      key: 'countryName',
      align: 'center',
      minWidth:100,
    },
    tableRegisterTime: {
      width: 150,
      title: '注册时间',
      key: 'registertime',
      render: (h, params) => {
        return h('div', Vue.prototype.$tiyBJTime(params.row.registertime));
      }
    },
    tableOrderTime: {
      width: 150,
      title: '交易时间',
      key: 'checkoutTime',
      render: (h, params) => {
        return h('div', Vue.prototype.$tiyBJTime(params.row.checkoutTime));
      }
    },
    tableRowState: tableRowStateTitle
  }
};

let role = {
  orderList: false,//订单管理
};

export  default  {
  tPage: page,
  tParams: params,
  tTable: table,
  tData: data,
  tRole: role
};
